<template>
	<view class="container">
	<uni-section title="发表评论" sub-title="" type="line">
		<uni-easyinput  v-model="comment" type="textarea" placeholder="请输入评论内容" />
		<button type="default" @click="tijiao">发表</button>
	</uni-section>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				comment:"",
				id:null,
				timer:null
			}
		},
		methods: {
tijiao(){
	uni.request({
		url: 'http://localhost:8090/foodapp/comment/addone',
		method: 'POST',
		data: {
			 "foodid": this.id,
			 "userid": 1,
			"comment": this.comment,
			 "postdate": "2022-09-09"
		},
		success: res => {
			if(res.data.success){
				uni.showToast({
					title: '评论发表成功',
					icon:'none'
				});
				this.timer = setInterval(() => {
uni.switchTab({
					url:'../../food/foodlist/foodlist'
				})
}, 2000);
				
			}
		},
		fail: () => {},
		complete: () => {}
	});
}
		},
		onLoad(e) {
			this.id=e.id
		}
	}
</script>

<style>
	.container {
		padding: 20px;
		font-size: 14px;
		line-height: 24px;
	}
</style>
